#-*-coding:UTF-8-*-
import socket
import time
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('127.0.0.1',9999))
s.listen(5)
while True:
	sock,addr = s.accept()
 	print 'accpet new connection from %s:%s...' %addr
	sock.send('Welcome')
	while True:
		data = sock.recv(1024)
		time.sleep(1)
		if data == 'exit' or not data:
			break 
		sock.send('hello %s' %data)
	sock.close()
	print 'connect from %s:%s is over' %addr
	
	
